﻿using System.Globalization;

namespace ODM.Data.Model
{
    public class Qualifier
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Qualifier"/> class.
        /// </summary>
        public Qualifier()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Qualifier"/> class.
        /// </summary>
        /// <param name="source">The source.</param>
        public Qualifier(Qualifier source)
        {
            this.ID = source.ID;
            this.Code = source.Code;
            this.Description = source.Description;
        }

        public int ID { get; set; }

        public string Code { get; set; }

        public string Description { get; set; }

        public override string ToString()
        {
            return string.Format(CultureInfo.CurrentUICulture, "{0} - {1}", this.ID, this.Code);
        }

        public static bool operator ==(Qualifier q1, Qualifier q2)
        {
            if (ReferenceEquals(q1, q2))
                return true;
            if (ReferenceEquals(q1, null) || ReferenceEquals(q2, null))
                return false;
            else
                return q1.GetHashCode() == q2.GetHashCode();
        }

        public static bool operator !=(Qualifier q1, Qualifier q2)
        {
            return !(q1 == q2);
        }

        public override bool Equals(object obj)
        {
            Qualifier q = obj as Qualifier;
            if (q == null)
                return false;

            return this == q;
        }

        public override int GetHashCode()
        {
            return string.Format(CultureInfo.InvariantCulture, "Qualifier:{0}{1}{2}", this.ID, this.Code, this.Description).GetHashCode();
        }
    }
}
